#include <cellcsp.h>
#include <string>
#include <stdio.h>
#include <csp_debug.h>




int main(){

	int block_all_dma=0, clear_spe_mem=0;

#ifdef BLOCK_ALL_DMA
	block_all_dma=1;
#endif

#ifdef CLEAR_SPE_MEM
	clear_spe_mem=1;
#endif

	ASSERT( block_all_dma );
	ASSERT( clear_spe_mem );
	
	CSPConfig conf;

	char *slow_starter2_mnemonic = "slow_starter_process";
	char 		  *alt_mnemonic = "alting_test_alt_process";
	char   *writer_a2o_mnemonic = "alting_test_writer_a2o_process";
	char *writer_o2o_1_mnemonic = "alting_test_writer_o2o_1_process";
	char *writer_o2o_2_mnemonic = "alting_test_writer_o2o_2_process";
	char *writer_o2o_3_mnemonic = "alting_test_writer_o2o_3_process";
	char *writer_o2o_4_mnemonic = "alting_test_writer_o2o_4_process";


	char *slow_starter2_path = "./tasks/alting_test_slow_writer_starter_process2";
	char 		  *alt_path = "./tasks/alting_test_alt_process";
	char   *writer_a2o_path = "./tasks/alting_test_writer_a2o_process";
	char *writer_o2o_1_path = "./tasks/alting_test_writer_o2o_1_process";
	char *writer_o2o_2_path = "./tasks/alting_test_writer_o2o_2_process";
	char *writer_o2o_3_path = "./tasks/alting_test_writer_o2o_3_process";
	char *writer_o2o_4_path = "./tasks/alting_test_writer_o2o_4_process";


	conf.add_csp_program(slow_starter2_path, slow_starter2_mnemonic); 
	conf.add_csp_program(		  alt_path, 	     alt_mnemonic); 
	conf.add_csp_program(  writer_a2o_path,   writer_a2o_mnemonic);
	conf.add_csp_program(writer_o2o_1_path, writer_o2o_1_mnemonic);
	conf.add_csp_program(writer_o2o_2_path, writer_o2o_2_mnemonic);
	conf.add_csp_program(writer_o2o_3_path, writer_o2o_3_mnemonic);
	conf.add_csp_program(writer_o2o_4_path, writer_o2o_4_mnemonic);


	CellCSP_start(conf);

	Parallel par(
		/* The alting processes. */
		new CSPProcess(alt_mnemonic), 

		/* This process starts all the writer processes - wit a 
		 * delay so we're sure that the alting-process is in the 
		 * wait-queue. 'slow_starter2' only run processes that 
		 * communicate one2one. */
		new CSPProcess(slow_starter2_mnemonic), 

		NULL);

	par.Run();

	CellCSP_end();
	
	return 0;
}
